package DAO;

import java.sql.*;

import Classes.Genre;
import DBConnection.ConnectionDB;

public class KlantDAO {

	
	 Connection con=null;
	 PreparedStatement prepStatement=null;
	 ResultSet rs=null;
	  
	 public KlantDAO(){
	   
	 }
	  
	 private Connection getConnection() throws SQLException{
		 Connection conn;
		 conn=ConnectionDB.getInstance().getConnection();
		 return conn;
	 }
	 
	 public boolean checkPwd(String gebNaam, String pWd){
		 try{
			 
			 String query = "SELECT * FROM Klanten WHERE GebruikersNaam = ? AND Paswoord = ?";
			 con = getConnection();
			 prepStatement = con.prepareStatement(query);
			 prepStatement.setString(1, gebNaam);
			 prepStatement.setString(2, pWd);
			 rs = prepStatement.executeQuery();
			 
			 while(rs.next()){
				 System.out.println("gelukt!");
				 return true;
				 
			 }
			 
			 
		 }catch(SQLException sqle){sqle.printStackTrace();}
		 finally{
			 if(con != null){
					try{con.close();}catch(SQLException se){}
			 }
		 }
		 System.out.println("mislukt!");
		 return false;
		 
		 
	 }
}
